﻿using System.Collections;
using System.Data;
using Lir.Common;
using QuickORM.Entity;

namespace QuickORM.Data
{
    public class T_ManagerInfoService : BaseDAL<T_ManagerInfo>
    {
        /// <summary>
        ///     将DataReader的属性值转化为实体类的属性值，返回实体类
        /// </summary>
        /// <param name="dr">有效的DataReader对象</param>
        /// <returns>实体类对象</returns>
        protected override T_ManagerInfo DataReaderToEntity(IDataReader dataReader)
        {
            var info = new T_ManagerInfo();
            var reader = new SmartDataReader(dataReader);

            info.M_Id = reader.GetInt32("M_Id");
            info.M_Project = reader.GetString("M_Project");
            info.M_Time = reader.GetDateTime("M_Time");
            info.M_Chief = reader.GetString("M_Chief");
            info.M_Content = reader.GetString("M_Content");
            info.M_Attch = reader.GetInt32("M_Attch");
            info.M_Type = reader.GetString("M_Type");

            return info;
        }

        /// <summary>
        ///     将实体对象的属性值转化为Hashtable对应的键值
        /// </summary>
        /// <param name="obj">有效的实体对象</param>
        /// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(T_ManagerInfo obj)
        {
            var info = obj;
            var hash = new Hashtable();
            hash.Add("M_Project", info.M_Project);
            hash.Add("M_Time", info.M_Time);
            hash.Add("M_Chief", info.M_Chief);
            hash.Add("M_Content", info.M_Content);
            hash.Add("M_Attch", info.M_Attch);
            hash.Add("M_Type", info.M_Type);

            return hash;
        }

        #region 对象实例及构造函数

        public static T_ManagerInfoService Instance
        {
            get { return new T_ManagerInfoService(); }
        }

        public T_ManagerInfoService()
            : base("T_Manager", "M_Id")
        {
        }

        #endregion
    }
}